#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'MiracleWong'

from io import BytesIO

f = BytesIO()
f.write('中文'.encode('utf-8'))
print(f.getvalue())

f1 = BytesIO(b'\xe4\xb8\xad\xe6\x96\x87')
print(f1.read())